using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.DirectX.Direct3D;

namespace Zsa.Emulation.Render.Video.Direct3d
{
    /// <summary>
    /// The direct3d render.
    /// </summary>
    public class Dx3dRenderCapabilities : GraphicRenderCapabilities
    {
        #region Constructor
        /// <summary>
        /// Initializes a new instance of the <see cref="T:D3dRenderCapabilities"/> class.
        /// </summary>
        public Dx3dRenderCapabilities()
            : base ( 1 )
        {
        }
        #endregion Constructor

        #region Methods
        /// <summary>
        /// Creates the settings for the item.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override GraphicRenderSettings CreateSettings(RenderDeviceItem item)
        {
            return new Dx3dRenderSettings(item);

        }

        /// <summary>
        /// Gets the devices supported by the render.
        /// </summary>
        /// <returns></returns>
        public override IList<RenderDeviceItem> GetDevices()
        {
            RenderDeviceItem[] _DeviceItems = new RenderDeviceItem[Manager.Adapters.Count];
            for ( int _TempIndex = 0; _TempIndex < _DeviceItems.Length; _TempIndex++ )
            {
                _DeviceItems[_TempIndex] = CreateDeviceItem(Manager.Adapters[_TempIndex]);
            }
            return _DeviceItems;
        }

        /// <summary>
        /// Creates the device item.
        /// </summary>
        /// <param name="adapterInformation">The adapter information.</param>
        /// <returns></returns>
        private RenderDeviceItem CreateDeviceItem(AdapterInformation adapterInformation)
        {
            return new RenderDeviceItem(
                adapterInformation.Information.Description,
                adapterInformation.Information.ToString(),
                RenderDeviceType.Video,
                adapterInformation.Information
                );
        }
        #endregion Methods

        #region Properties
        /// <summary>
        /// Gets the default device.
        /// </summary>
        /// <value></value>
        public override RenderDeviceItem DefaultDevice
        {
            get
            {
                return CreateDeviceItem(Manager.Adapters.Default);
            }
        }
        #endregion Properties
    }
}
